require 'rsolr'

class PeController < ApplicationController
  def findincipit
    def reducecode(s)
      res=[]
      aa=""
      code=s.split("")
      a=code
      code.each do |l|
        res << ["pe:"+a.join]
        a.pop
      end
      return res.join("~0.9 OR ")+"~0.9"
    end
    solr = RSolr.connect :url => 'http://lab.rism.info:8983/solr/collection1/'
    # solr = RSolr.connect :url => 'http://solrserver.com', :proxy=>'http://user:pass@proxy.example.com:8080'
    #
    # # send a request to /select
    #
    # # send a request to /catalog
    # response = solr.get 'catalog', :params => {:q => '*:*'}



    if params[:pefield]

      @code=params[:pefield]
      @cc=reducecode(@code)
      @nodes = solr.get 'select', :params => {:q => @cc, :rows=>200}
      @countno=@nodes.size if @nodes.size > 0
    end
  end
   

end

